import Vue from "vue";
import Vuex from "vuex";
import createLogger from "vuex/dist/logger";

import * as actions from "./actions";
import * as getters from "./getters";
import mutations from "./mutations";
import { getToken, readCompanyId } from "@/utils/storage";

const { NODE_ENV, VUE_APP_PARAMS } = process.env;

Vue.use(Vuex);

const state = {
  token: getToken(),
  companyId: readCompanyId(),
  cityInfo: {},
  userInfo: {},
  routerMap: [],
  color: [
    "#60acfc",
    "#32d3eb",
    "#5bc49f",
    "#feb64d",
    "#ff7c7c",
    "#9287e7",
    "#668ED6",
    "#B55CBD"
  ]
};

const plugins = [...(NODE_ENV !== "productioin" ? [createLogger()] : [])];

const store = new Vuex.Store({
  actions,
  getters,
  state,
  mutations,
  plugins
});
export default store;
